///////////////////////////////////////////////////////////
// 
//  DotLocate.h
//
//  Wiicussion
//  HCI 575 Class project
//  Spring 2007
// 
//  Authors:  Jeremy Bennett
//            Adam Faeth
//            Michael Oren
//
///////////////////////////////////////////////////////////

#ifndef _DOT_LOCATE_H_
#define _DOT_LOCATE_H_

// 3-D Point
struct Point3D
{
    float fX;
    float fY;
    float fZ;
};


// 2-D Point (a Dot)
struct Dot
{
    float fX;
    float fY;
    Dot(void) : fX(0), fY(0) { }
    Dot(float fPosX, float fPosY) 
    :  fX(fPosX), 
       fY(fPosY)
    {
        // do nothing
    }
};


// Location is a 3d position in space and a 2-d point-at position on screen
struct Location
{
    Point3D pos;
    Dot point;
};


//
class DotLocate
{
  public:
    // Constructor/destructor
    DotLocate::DotLocate(float fMaxHeight, float fMaxDist, float fPixelCm);
    ~DotLocate();
    
    // determines a location from 4 dots
    bool locate(const Dot &rLeftBottom, const Dot &rRightBottom, 
                const Dot &rRightTop, const Dot &rLeftTop, 
                Location &rLoc);
                
    // Calculates 2 axis of a location from 3 edges of a known square                  
    bool twoAxisLoc(const float &fDistA, 
                    const float &fDistB, 
                    const float &fDistC, 
                    float &fX, 
                    float &fY);
    
    // prints out the location
    void print(Location & rLoc);
    
  protected:
    // Distance between two dots
    float _dist(const Dot &rLhs, const Dot &rRhs) const;
    
  protected:
    // Scaling factors / environment
    float _fPxCm; // The conversion from pixels to cm
    float _fMaxDist; // The distance in pixels out of the screen when the dots are 1 pixel apart
    float _fMaxHeight; // The maximum possible height/space between two dots
};


struct DotMatrix
{
    Dot pTopLeft;
    Dot pBottomLeft;
    Dot pBottomRight;
    Dot pTopRight;
};

#endif  // _DOT_LOCATE_H_
